<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="工位" prop="station">
        <el-input
          v-model="queryParams.station"
          placeholder="请输入工位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="数模焊点号" prop="sjNumber">
        <el-input
          v-model="queryParams.sjNumber"
          placeholder="请输入焊点号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="机器人名称" prop="Robot">
        <el-select
          v-model="queryParams.robot"
          placeholder="请选择机器人型号"
          clearable
          @keyup.enter.native="handleQuery"
          @change="handleSelectChange" >
          <el-option
            v-for="item in midList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="规范号" prop="gaugeNumber">
        <el-input
          v-model="queryParams.gaugeNumber"
          placeholder="请输入规范号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="材质1" prop="material1">
        <el-input
          v-model="queryParams.material1"
          placeholder="请输入材质1"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="材质1厚度(mm)" prop="materialThickness1">
        <el-input
          v-model="queryParams.materialThickness1"
          placeholder="请输入材质1厚度(mm)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="涂胶1" prop="gumming1">
        <el-input
          v-model="queryParams.gumming1"
          placeholder="请输入涂胶1"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="材质2" prop="material2">
        <el-input
          v-model="queryParams.material2"
          placeholder="请输入材质2"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="材质2厚度(mm)" prop="materialThickness2">
        <el-input
          v-model="queryParams.materialThickness2"
          placeholder="请输入材质2厚度(mm)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="涂胶2" prop="gumming2">
        <el-input
          v-model="queryParams.gumming2"
          placeholder="请输入涂胶2"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="材质3" prop="material3">
        <el-input
          v-model="queryParams.material3"
          placeholder="请输入材质3"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="材质3厚度(mm)" prop="materialThickness3">
        <el-input
          v-model="queryParams.materialThickness3"
          placeholder="请输入材质3厚度(mm)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="涂胶3" prop="gumming3">
        <el-input
          v-model="queryParams.gumming3"
          placeholder="请输入涂胶3"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="材质4" prop="material4">
        <el-input
          v-model="queryParams.material4"
          placeholder="请输入材质4"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="材质4厚度(mm)" prop="materialThickness4">
        <el-input
          v-model="queryParams.materialThickness4"
          placeholder="请输入材质4厚度(mm)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          @click="handleClear"
        >清空数据</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload"
          size="mini"
          @click="handleImport"
        >导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          @click="handleGenerate"
        >生成</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          :plain="!isActive1"
          :class="{ 'active1-style': isActive1 }"
          size="mini"
          @click="toggleColorLabel"
        >标注未匹配的搭接组合</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
        >焊接/机器人</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport1"
        >模板表</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport2"
        >工艺验证表</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="Dump"
        >转存</el-button>
      </el-col>

      <el-col :span="1.5">
        <el-select v-model="matchStatus" :placeholder= matchStatus  size="mini" style="width:90px;margin-right:4px;">
          <el-option label="全部" value="all"/>
          <el-option label="已匹配" value="matched"/>
          <el-option label="未匹配" value="unmatched"/>
        </el-select>
        <el-button type="primary" size="mini" @click="doMatchFilter">确定</el-button>
      </el-col>

      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <div class="table-container">
      <el-button
        class="fullscreen-btn"
        icon="el-icon-full-screen"
        circle
        size="mini"
        @click="toggleFullscreen"
      />
    <el-table
      v-loading="loading"
      :data="weldList"
      @selection-change="handleSelectionChange"
      border
      style="width: 100%;"
      :show-overflow-tooltip="true"
      empty-text="暂无数据"
      :cell-style="cellStyle"
    >
    <el-table-column type="selection" align="center" width="55"></el-table-column>
    <el-table-column label="序号" type="index" align="center">
      <template #default="scope">
        <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
      </template>
    </el-table-column>
      <el-table-column label="车型" align="center" prop="vehicleType" />
      <el-table-column label="工位" align="center" prop="station" />
      <el-table-column label="机器人名称" align="center" prop="robot" />
      <el-table-column label="焊枪编号" align="center" prop="torchNumber" />
      <el-table-column label="焊点号(五位焊点号)" align="center" prop="solderJoint" />
      <el-table-column label="数模焊点号" align="center" prop="sjNumber" />
      <el-table-column label="焊点坐标(X)" align="center" prop="x" />
      <el-table-column label="焊点坐标(Y)" align="center" prop="y" />
      <el-table-column label="焊点坐标(Z)" align="center" prop="z" />
      <el-table-column label="规范号" align="center" prop="gaugeNumber" />
      <el-table-column label="电极形式" align="center" prop="electrodeForm" />
      <el-table-column label="频率" align="center" prop="parametricForm" />
      <el-table-column label="额定压力" align="center" prop="ratedPressure" />
      <el-table-column label="Product" align="center" prop="product" />
      <el-table-column label="JCPN1" align="center" prop="jcpn1" />
      <el-table-column label="材质1" align="center" prop="material1" />
      <el-table-column label="材质1厚度(mm)" align="center" prop="materialThickness1" />
      <el-table-column label="涂胶1" align="center" prop="gumming1" />
      <el-table-column label="JCPN2" align="center" prop="jcpn2" />
      <el-table-column label="材质2" align="center" prop="material2" />
      <el-table-column label="材质2厚度(mm)" align="center" prop="materialThickness2" />
      <el-table-column label="涂胶2" align="center" prop="gumming2" />
      <el-table-column label="JCPN3" align="center" prop="jcpn3" />
      <el-table-column label="材质3" align="center" prop="material3" />
      <el-table-column label="材质3厚度(mm)" align="center" prop="materialThickness3" />
      <el-table-column label="涂胶3" align="center" prop="gumming3" />
      <el-table-column label="JCPN4" align="center" prop="jcpn4" />
      <el-table-column label="材质4" align="center" prop="material4" />
      <el-table-column label="材质4厚度(mm)" align="center" prop="materialThickness4" />
      <el-table-column label="压力(N)" align="center" prop="stress" />
      <el-table-column label="预压时间(ms)" align="center" prop="preloadingTime" />
      <el-table-column label="加压时间(ms)" align="center" prop="pressurizationTime" />
      <el-table-column label="预热方式" align="center" prop="preheatingMethod" />
      <el-table-column label="预热时间(ms)" align="center" prop="preheatingTime" />
      <el-table-column label="预热电流(kA)" align="center" prop="preheatingCurrent" />
      <el-table-column label="冷却时间(ms)" align="center" prop="coolingTime" />
      <el-table-column label="焊接方式" align="center" prop="weldingMethod" />
      <el-table-column label="递增递减" align="center" prop="increaseDecrease" />
      <el-table-column label="递增时间(ms)" align="center" prop="incrementalTime" />
      <el-table-column label="起始电流(KA)" align="center" prop="startingCurrent" />
      <el-table-column label="焊接时间(ms)" align="center" prop="weldingTime" />
      <el-table-column label="焊接电流(kA)" align="center" prop="weldingCurrent" />
      <el-table-column label="递减时间(ms)" align="center" prop="declineTime" />
      <el-table-column label="终止电流(KA)" align="center" prop="terminationCurrent" />
      <el-table-column label="冷却时间(ms)" align="center" prop="coolingTime1" />
      <el-table-column label="脉冲次数" align="center" prop="pulseFrequency" />
      <el-table-column label="冷却时间(ms)" align="center" prop="coolingTime2" />
      <el-table-column label="回火方式" align="center" prop="temperingMethod" />
      <el-table-column label="回火时间(ms)" align="center" prop="temperingTime" />
      <el-table-column label="回火电流(kA)" align="center" prop="temperingCurrent" />
      <el-table-column label="保持时间(ms)" align="center" prop="holdTime" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
</div>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="handlePage"
    />

    <!-- 导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls, .csv"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的数据
          </div>
          <span>仅允许导入xls、xlsx、csv格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="Export.title" :visible.sync="Export.open" width="400px" append-to-body>
      <span>是否导出全部数据</span>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="ExportAll">确 定</el-button>
        <el-button @click="Export.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="Export1.title" :visible.sync="Export1.open" width="400px" append-to-body>
      <span>是否存储数据</span>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dump">确 定</el-button>
        <el-button @click="Export1.open = false">取 消</el-button>
      </div>
    </el-dialog>
</div>
</template>

<script>
import {
  getWelding,
  delWelding,
  addWelding,
  updateWelding,
  generateWelding,
  listAllWelding
} from "@/api/WELD/welding";
import { getToken } from "@/utils/auth";
import axios from "axios";
import {EventBus} from "@/main";

export default {
  name: "WELD",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      //下拉框存储的数据
      midList:[],
      // 存储用户选择的数据项
      multipleSelection: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch:false,
      // 总条数
      total: 0,
      //查的全部数据
      allData: [],
      // 当前页面表数据
      weldList: [],
      // 表单参数
      form: {},
      //导入文件的名称
      importFileName: null,
      //是否开启标注
      isColorLabelEnabled:false,
      //按键的颜色开关
      isActive1: false,
      //筛选默认全部数据
      matchStatus: 'all',
      // excel导入参数
      upload:{
        open: false,
        title: "",
        // // 是否禁用上传
        isUploading: false,
        // // 是否更新已经存在的数据
        updateSupport: 0,
        headers: { Authorization: "Bearer " + getToken() },
        url: process.env.VUE_APP_BASE_API + "/Welding/welding/importData"
      },

      // 导出参数
      Export:{
        open: false,
        title: "",
      },
      // 导出参数
      Export1:{
        open: false,
        title: "",
      },
      //分页参数
      queryParams: {
        pageNum: 1,
        pageSize: 50,
        ipaddr: undefined,
        name:undefined,
        tableName: undefined,
        tableComment: '' // 假设这是下拉列表绑定的模型
      },
      // 表单重置
      reset() {
        this.form = {
          ID: undefined, sjNumber: undefined,
          robot: undefined, gaugeNumber: undefined,
          position: undefined, electrodeForm: undefined,
          material1: undefined, materialThickness1: undefined,
          gumming1: undefined, material2: undefined,
          materialThickness2: undefined, gumming2: undefined,
          material3: undefined, materialThickness3: undefined,
          gumming3: undefined, material4: undefined,
          materialThickness4: undefined, stress: undefined,
          preloadingTime: undefined, preheatingTime: undefined,
          preheatingCurrent: undefined, coolingTime: undefined,
          incrementalTime: undefined, startingCurrent: undefined,
          weldingTime: undefined, weldingCurrent: undefined,
          coolingTime1: undefined, declineTime: undefined,
          terminationCurrent: undefined, pulseFrequency: undefined,
          coolingTime2: undefined, temperingTime: undefined,
          temperingCurrent: undefined, holdTime: undefined,
          parametricForm: undefined
        };
        this.resetForm("form");
      },

    };
  },
  //页面自动执行的方法
  created() {
    // 从 localStorage 中恢复 importFileName
    const storedFileName = localStorage.getItem('importFileName');
    if (storedFileName) {
      this.importFileName = storedFileName;
    }else{
      this.importFileName = '表.xlsx';
    }
    this.getList();
  },
  methods: {
    //查询表格数据
    getList(){
      this.doMatch();
    },
    //筛选数据是否匹配成功
    doMatchFilter() {
      this. doMatch();
      this.$modal.msgSuccess('筛选完成');
    },
    doMatch() {
      this.loading = true
      listAllWelding(this.queryParams).then(res => {
        this.allData = res.rows
        if (this.matchStatus === 'matched')
          this.allData = this.allData.filter(r => !(r.stress == null || r.stress === ''))
        else if (this.matchStatus === 'unmatched')
          this.allData = this.allData.filter(r => (r.stress == null || r.stress === ''))

        this.allData.forEach(element=>{
          const robot=element.robot;
          const isDuplicate=this.midList.some(item=>item.label===robot && item.value===robot);
          if (!isDuplicate){
            this.midList.push({label:element.robot,value:element.robot});
          }
        })
        this.total = this.allData.length;
        this.slicePage();
        this.loading = false
      }).catch(err=>{
        console.log(err);
      })
    },
    // 纯前端切片
    slicePage() {
      const { pageNum, pageSize } = this.queryParams
      const start = (pageNum - 1) * pageSize
      const end   = start + pageSize
      this.weldList = this.allData.slice(start, end)
    },
    // 翻页/每页条数切换时触发
    handlePage({ page, limit }) {
      this.queryParams.pageNum = page
      this.queryParams.pageSize = limit
      this.slicePage()
    },
    // 搜索按钮操作
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 重置按钮操作
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
      this.multipleSelection =selection;
    },
    // 修改按钮操作
    handleUpdate(row) {
      this.reset();
      const ID = row.ID || this.ids
      getWelding(ID).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改";
      });
    },
   // 删除按钮操作
    handleDelete(row) {
      const Ids = row.ID || this.ids;
      let displayIds=Ids;
      if (Ids.length>10){
        displayIds=Ids.slice(0,10)+"...";
      }
      this.$modal.confirm('是否确认删除编号为"' + displayIds + '"的数据项？').then(() => {
        delWelding(Ids).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch((error) => {
          this.$modal.msgError("删除失败：" + error.message);
        });
      }).catch(() => {});
    },
    //清空数据
    handleClear(){
      this.$modal.confirm('是否确认清空所有数据项？').then(() =>{
           axios.delete('/dev-api/Welding/welding/clear',{
             headers: {
               // 将 token 添加到请求头中，通常是 'Authorization' 头
               'Authorization': `Bearer ${getToken()}`
             }
           }).then(res=>{
             if (res.data.code===200){
               this.$modal.msgSuccess(res.data.message||"清空成功！");
               this.getList();
             }else {
               this.$modal.msgSuccess(res.data.message||"清空失败！");
             }
      }).catch(err=>{
           this.$modal.msgError("请求异常：" + err.message);
      });
      }).catch(() => {});
      this.getList();
    },
    // 导出焊接/机器人按钮操作
    handleExport() {
      if (this.multipleSelection.length===0){
        this.$message({
          message:"请选择导出数据",
          type: "warning",
        });
        return ;
      }
      const ids=this.multipleSelection.map(item => item.id).join(',');
      this.download('Welding/welding/export1', {ids}, `weld_${new Date().getTime()}.xlsx`)
      this.download('Welding/welding/export2', {ids}, `weld_${new Date().getTime()}.xlsx`)
    },
    //导出模板表按钮操作
    handleExport1() {
      if (this.multipleSelection.length===0){
        this.Export.title = "数据导入";
        this.Export.open = true;
      }else {
        const ids = this.multipleSelection.map(item => item.id).join(',');
        this.download('Welding/welding/export3', {ids}, `${this.importFileName}`)
      }
    },
    ExportAll(){
      this.download('Welding/welding/exportAll',1,`${this.importFileName}`);
      this.Export.open = false;
    },
    //导出工艺验证表
    handleExport2(){
      this.download('Welding/welding/exportAll2',1,`${this.importFileName}`);
    },
    // 转存
    Dump(){
      this.Export1.title = "数据存储";
      this.Export1.open = true;
    },
    dump(row){
      // 判断是否有选中的数据
      if (this.multipleSelection.length > 0) {
        // 如果有选中的数据，保存选中的数据到另一个表
        const Ids = row.ID || this.ids;
        let selectedIds = Ids;
        console.log(Ids);
        this.saveToAnotherTable(selectedIds, true); // true 表示只保存选中的数据
      } else {
        // 如果没有选中的数据，保存全部数据到另一个表
        this.saveToAnotherTable(null, false); // false 表示保存全部数据
      }
      this.Export1.open = false; // 关闭弹窗
    },
    saveToAnotherTable(ids, isPartial) {
      // 定义接口地址
      const url = isPartial ? '/dev-api/DataStation/dataStation/saveSelected' : '/dev-api/DataStation/dataStation/saveAll';
      // 调用接口
      axios.post(url, {
        ids: ids // 如果 isPartial 为 true，ids 是选中的数据 ID 列表；否则为 null
      },{
        headers: {
          // 将 token 添加到请求头中，通常是 'Authorization' 头
          'Authorization': `Bearer ${getToken()}`
        }
      }).then(() => {
        this.$modal.msgSuccess("转存成功！");
        // 触发事件，通知第二个页面刷新
        EventBus.$emit('refreshAnotherTable');
      }).catch(err => {
        this.$modal.msgError("转存失败：" + err.message);
      });
    },

    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },

    // 提交按钮
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id !== undefined) {
            updateWelding(this.form).then(() => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addWelding(this.form).then(() => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    // 导入按钮操作
    handleImport() {
      this.upload.title = "excel文件导入";
      this.upload.open = true;
    },

   // 下载模板操作
    importTemplate() {
      this.download('Welding/welding/importTemplate', {
      }, `XXX项目焊接参数导入模版.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgress() {
      this.upload.isUploading = true;
    },
    // 文件导入
    handleFileSuccess(response, file) {
      // 1. 保存文件名
      this.importFileName = file.name;
      localStorage.setItem('importFileName', this.importFileName);

      // 2. 拿到后端原始数据（中文 key）
      const list = response.data || response.rows || [];

      // 3. 更新本地数据并关闭弹窗
      this.weldList = list;
      this.total = list.length;
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(
        `<div style="overflow:auto;max-height:70vh;padding:10px 20px 0;">${response.msg}</div>`,
        '导入结果',
        { dangerouslyUseHTMLString: true }
      );
      this.getList();
    },

    //生成按键
    handleGenerate() {
      generateWelding(this.queryParams).then(() => {
        this.getList();
        this.$modal.msgSuccess("生成成功");
      }).catch(() => {});
    },

    //对比按键
    cellStyle({ row, columnIndex}){
      //控制是否开启颜色标注
      if (!this.isColorLabelEnabled) {
        return '';
      }
      if (columnIndex===1) {
        // 获取第20列的值
        const stressValue = row.stress;
        // 判断第20列的值是否为空或null
        if (stressValue == null || stressValue === "") {
          return 'background-color:red';
        }}
      // 如果不符合条件，返回空字符串，表示不改变样式
      return '';
    },

      //颜色标注开关（取反控制）
    toggleColorLabel() {
      this.isColorLabelEnabled = !this.isColorLabelEnabled;
      this.isActive1 = !this.isActive1;
    },

    //搜索框里面的下拉的数据选择
    handleSelectChange(newValue) {
      // 当选择的值变化时，这里将接收新的值作为参数
      console.log('选中的值变化为:', newValue);
      // 在这里可以执行进一步的逻辑处理
    },

    toggleFullscreen() {
      const elem = document.querySelector('.table-container');
      if (!document.fullscreenElement) {
        elem.requestFullscreen().then(() => {
          this.$nextTick(() => {
            this.$refs.table.doLayout();   // 重算列宽
          });
        });
      } else {
        document.exitFullscreen();
      }
    }
  }
};
</script>


<style scoped>

.active1-style {
background-color: #ff9800 !important; /* 橙色背景 */
color: #ffffff !important; /* 白色文字 */
border-color: #ff9800 !important; /* 橙色边框 */
}

.table-container {
  position: relative;
}

.fullscreen-btn {
  position: absolute;
  top: -36px;      /* 距离容器顶部 8px */
  right: 75px;    /* 距离容器右侧 8px */
  z-index: 10;
}
</style>

<style>
:fullscreen .el-table {
  height: 100vh !important;
}
:fullscreen.table-container .el-table__body-wrapper {
  max-height: calc(96vh - 30px) !important;
}
</style>

